/*
 * Copyright 2008-2010 GP Software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 * AbstractMockUsersFileGenerator.java | Created on Jul 19, 2010
 */
package org.gp.fileGenerator.mock;

import org.gp.fileGenerator.AbstractFileGenerator;
import org.gp.fileGenerator.model.User;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * A dummy file generator that outputs a users list to the console
 *
 * @author Paul Augustine C. Mendoza
 */
public abstract class AbstractMockUsersFileGenerator<T> extends AbstractFileGenerator<T> {

    private static final String MODEL_ID = "users";

    public AbstractMockUsersFileGenerator(String templateRoot,
                                          String template) {
        super(templateRoot, template);
    }

    public File generate() {
        setRootDataModel(MODEL_ID, getDataModel());
        try {
            generateOutput(System.out);
        } catch (IOException ioe) {
            getLogger().error("Error in generating file.", ioe);
        }
        return null;
    }

    public abstract T getDataModel();

    protected List<User> getUsers() {
        List<User> users = new ArrayList<User>();
        users.add(new User("Paul Augustine", "Mendoza"));
        users.add(new User("Jan Michael", "Yu"));
        users.add(new User("Liza", "AGAPINAN-DE GUZMAN"));
        users.add(new User("Richard", "Villaber"));
        users.add(new User("Vincent", "Lim"));
        users.add(new User("Edwin", "Guillartes"));
        return users;
    }

}
